#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/linux-event-codes.h>
#include <dt-bindings/iio/qcom,spmi-vadc.h>
#include "lagoon-audio-overlay.dtsi"
#include "lagoon-sde-display.dtsi"
#include "camera/lagoon-camera-sensor-mtp.dtsi"
#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
#include "lagoon-thermal-overlay.dtsi"

&soc {
	gpio_keys {
		compatible = "gpio-keys";
		label = "gpio-keys";

		pinctrl-names = "default";
		pinctrl-0 = <&key_vol_up_default>;

		vol_up {
			label = "volume_up";
			gpios = <&pm6350_gpios 2 GPIO_ACTIVE_LOW>;
			linux,input-type = <1>;
			linux,code = <KEY_VOLUMEUP>;
			gpio-key,wakeup;
			debounce-interval = <15>;
			linux,can-disable;
		};
	};

	qrd_batterydata: qcom,battery-data {
		qcom,batt-id-range-pct = <15>;
		#include "qg-batterydata-atl436186020H_3780mAh.dtsi"
		#include "qg-batterydata-atl466271_3300mAh.dtsi"
	};
};

&pm6150a_l1 {
	qcom,init-voltage = <1800000>;
};

&pm6350_gpios {
	key_vol_up {
		key_vol_up_default: key_vol_up_default {
			pins = "gpio2";
			function = "normal";
			input-enable;
			bias-pull-up;
			power-source = <0>;
		};
	};
};

&ufsphy_mem {
	compatible = "qcom,ufs-phy-qmp-v3";

	vdda-phy-supply = <&L18A>;
	vdda-pll-supply = <&L22A>;
	vdda-phy-max-microamp = <62900>;
	vdda-pll-max-microamp = <18300>;

	status = "ok";
};

&ufshc_mem {
	vdd-hba-supply = <&gcc_ufs_phy_gdsc>;
	vdd-hba-fixed-regulator;
	vcc-supply = <&L7E>;
	vcc-voltage-level = <2950000 2960000>;
	vccq2-supply = <&L12A>;
	vccq2-voltage-level = <1800000 1800000>;
	vcc-max-microamp = <800000>;
	vccq2-min-microamp = <0>;
	vccq2-max-microamp = <800000>;
	vccq2-pwr-collapse-sup;

	qcom,vddp-ref-clk-supply = <&L22A>;
	qcom,vddp-ref-clk-max-microamp = <100>;
	qcom,vddp-ref-clk-min-uV = <1152000>;
	qcom,vddp-ref-clk-max-uV = <1200000>;
	status = "ok";
};

&sdhc_1 {
	vdd-supply = <&L7E>;
	qcom,vdd-voltage-level = <2960000 2960000>;
	qcom,vdd-current-level = <0 570000>;

	vdd-io-supply = <&L12A>;
	qcom,vdd-io-always-on;
	qcom,vdd-io-lpm-sup;
	qcom,vdd-io-voltage-level = <1800000 1800000>;
	qcom,vdd-io-current-level = <0 325000>;

	pinctrl-names = "active", "sleep";
	pinctrl-0 = <&sdc1_clk_on &sdc1_cmd_on &sdc1_data_on
					&sdc1_rclk_on>;
	pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off
					&sdc1_rclk_off>;

	status = "ok";
};

&sdhc_2 {
	vdd-supply = <&L9E>;
	qcom,vdd-voltage-level = <2960000 2960000>;
	qcom,vdd-current-level = <0 800000>;

	vdd-io-supply = <&L6E>;
	qcom,vdd-io-voltage-level = <1800000 2950000>;
	qcom,vdd-io-current-level = <0 22000>;

	pinctrl-names = "active", "sleep";
	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &sdc2_data_on &sdc2_cd_on>;
	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;

	cd-gpios = <&tlmm 94 GPIO_ACTIVE_LOW>;

	status = "ok";
};

&pm6150a_amoled {
	status = "ok";
};

&dsi_r66451_amoled_60hz_video {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_dcs";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <255>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,platform-reset-gpio = <&pm6150l_gpios 9 0>;
};

&dsi_r66451_amoled_90hz_video {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_dcs";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <255>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,platform-reset-gpio = <&pm6150l_gpios 9 0>;
};

&dsi_r66451_amoled_120hz_video {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_dcs";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <255>;
	qcom,mdss-dsi-bl-inverted-dbv;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,platform-reset-gpio = <&pm6150l_gpios 9 0>;
};

&dsi_r66451_amoled_60hz_cmd {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_dcs";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <255>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,platform-te-gpio = <&tlmm 23 0>;
	qcom,platform-reset-gpio = <&pm6150l_gpios 9 0>;
};

&dsi_r66451_amoled_90hz_cmd {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_dcs";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <255>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,platform-te-gpio = <&tlmm 23 0>;
	qcom,platform-reset-gpio = <&pm6150l_gpios 9 0>;
};

&dsi_r66451_amoled_120hz_cmd {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_dcs";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <255>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,mdss-dsi-bl-inverted-dbv;
	qcom,platform-te-gpio = <&tlmm 23 0>;
	qcom,platform-reset-gpio = <&pm6150l_gpios 9 0>;
};

&sde_dsi {
	qcom,dsi-default-panel = <&dsi_r66451_amoled_120hz_video>;
};

&qupv3_se0_i2c {
	status = "ok";
	#address-cells = <1>;
	#size-cells = <0>;
	nq@28 {
		compatible = "qcom,nq-nci";
		reg = <0x28>;
		qcom,nq-irq = <&tlmm 9 0x00>;
		qcom,nq-ven = <&tlmm 6 0x00>;
		qcom,nq-firm = <&tlmm 8 0x00>;
		qcom,nq-clkreq = <&tlmm 7 0x00>;
		qcom,nq-vdd-1p8-supply = <&L11A>;
		qcom,nq-vdd-1p8-voltage = <1800000 1800000>;
		qcom,nq-vdd-1p8-current = <157000>;
		interrupt-parent = <&tlmm>;
		interrupts = <9 0>;
		interrupt-names = "nfc_irq";
		pinctrl-names = "nfc_active", "nfc_suspend";
		pinctrl-0 = <&nfc_int_active &nfc_enable_active
				&nfc_clk_req_active>;
		pinctrl-1 = <&nfc_int_suspend &nfc_enable_suspend
				&nfc_clk_req_suspend>;
	};
};

&pm7250b_charger {
	status = "ok";
	io-channels = <&pm7250b_vadc ADC_USB_IN_V_16>,
		      <&pm7250b_vadc ADC_USB_IN_I>,
		      <&pm7250b_vadc ADC_CHG_TEMP>,
		      <&pm7250b_vadc ADC_DIE_TEMP>,
		      <&pm7250b_vadc ADC_AMUX_THM3_PU2>,
		      <&pm7250b_vadc ADC_SBUx>,
		      <&pm7250b_vadc ADC_VPH_PWR>,
		      <&pm7250b_vadc ADC_AMUX_THM1_PU2>;
	io-channel-names = "usb_in_voltage",
			   "usb_in_current",
			   "chg_temp",
			   "die_temp",
			   "conn_temp",
			   "sbux_res",
			   "vph_voltage",
			   "skin_temp";
	qcom,battery-data = <&qrd_batterydata>;
	qcom,sec-charger-config = <1>;
	qcom,auto-recharge-soc = <98>;
	qcom,step-charging-enable;
	qcom,sw-jeita-enable;
	qcom,charger-temp-max = <800>;
	qcom,smb-temp-max = <800>;
	qcom,suspend-input-on-debug-batt;
	qcom,fcc-stepping-enable;
	qcom,fcc-step-delay-ms = <100>;
	qcom,fcc-step-size-ua = <100000>;
	qcom,smb-internal-pull-kohm = <0>;
	qcom,en-skin-therm-mitigation;
	qcom,thermal-mitigation = <10000000 9500000 9000000 8500000 8000000
				7500000 7000000 6500000 6000000 5500000 5000000 4500000
				4000000 3500000 3000000 2500000 2000000 1500000 1000000
				500000>;
};

&pm7250b_qg {
	status = "ok";
	io-channels = <&pm7250b_vadc ADC_BAT_THERM_PU2>,
		      <&pm7250b_vadc ADC_BAT_ID_PU2>;
	io-channel-names = "batt-therm",
			   "batt-id";
	qcom,qg-iterm-ma = <150>;
	qcom,hold-soc-while-full;
	qcom,linearize-soc;
	qcom,cl-feedback-on;
	qcom,tcss-enable;
	qcom,fvss-enable;
	qcom,fvss-vbatt-mv = <3300>;
	qcom,bass-enable;
	qcom,use-cp-iin-sns;
};

&wcd937x_codec {
	status = "ok";
};

&wcd938x_codec {
	status = "disabled";
};

&wcd937x_rx_slave {
	status = "ok";
};

&wcd937x_tx_slave {
	status = "ok";
};

&wcd938x_tx_slave {
	status = "disabled";
};

&wcd938x_rx_slave {
	status = "disabled";
};

&lagoon_snd {
	qcom,model = "lito-lagoonqrd-snd-card";
	qcom,msm-mi2s-master = <1>, <1>, <1>, <1>, <1>, <1>;
	qcom,wcn-btfm = <1>;
	qcom,audio-routing =
		"AMIC1", "MIC BIAS1",
		"MIC BIAS1", "Analog Mic1",
		"AMIC2", "MIC BIAS2",
		"MIC BIAS2", "Analog Mic2",
		"AMIC3", "MIC BIAS3",
		"MIC BIAS3", "Analog Mic3",
		"AMIC4", "MIC BIAS1",
		"MIC BIAS1", "Analog Mic4",
		"TX DMIC0", "MIC BIAS3",
		"MIC BIAS3", "Digital Mic0",
		"TX DMIC1", "MIC BIAS3",
		"MIC BIAS3", "Digital Mic1",
		"TX DMIC2", "MIC BIAS1",
		"MIC BIAS1", "Digital Mic2",
		"TX DMIC3", "MIC BIAS1",
		"MIC BIAS1", "Digital Mic3",
		"TX DMIC4", "MIC BIAS4",
		"MIC BIAS4", "Digital Mic4",
		"TX DMIC5", "MIC BIAS4",
		"MIC BIAS4", "Digital Mic5",
		"IN1_HPHL", "HPHL_OUT",
		"IN2_HPHR", "HPHR_OUT",
		"IN3_AUX", "AUX_OUT",
		"TX SWR_ADC0", "ADC1_OUTPUT",
		"TX SWR_ADC2", "ADC2_OUTPUT",
		"TX SWR_ADC3", "ADC3_OUTPUT",
		"TX SWR_DMIC0", "DMIC1_OUTPUT",
		"TX SWR_DMIC1", "DMIC2_OUTPUT",
		"TX SWR_DMIC2", "DMIC3_OUTPUT",
		"TX SWR_DMIC3", "DMIC4_OUTPUT",
		"TX SWR_DMIC4", "DMIC5_OUTPUT",
		"TX SWR_DMIC5", "DMIC6_OUTPUT",
		"TX SWR_DMIC6", "DMIC7_OUTPUT",
		"TX SWR_DMIC7", "DMIC8_OUTPUT",
		"WSA SRC0_INP", "SRC0",
		"WSA_TX DEC0_INP", "TX DEC0 MUX",
		"WSA_TX DEC1_INP", "TX DEC1 MUX",
		"RX_TX DEC0_INP", "TX DEC0 MUX",
		"RX_TX DEC1_INP", "TX DEC1 MUX",
		"RX_TX DEC2_INP", "TX DEC2 MUX",
		"RX_TX DEC3_INP", "TX DEC3 MUX",
		"SpkrLeft IN", "WSA_SPK1 OUT",
		"VA_AIF1 CAP", "VA_SWR_CLK",
		"VA_AIF2 CAP", "VA_SWR_CLK",
		"VA_AIF3 CAP", "VA_SWR_CLK",
		"VA MIC BIAS3", "Digital Mic0",
		"VA MIC BIAS3", "Digital Mic1",
		"VA MIC BIAS1", "Digital Mic2",
		"VA MIC BIAS1", "Digital Mic3",
		"VA MIC BIAS4", "Digital Mic4",
		"VA MIC BIAS4", "Digital Mic5",
		"VA DMIC0", "VA MIC BIAS3",
		"VA DMIC1", "VA MIC BIAS3",
		"VA DMIC2", "VA MIC BIAS1",
		"VA DMIC3", "VA MIC BIAS1",
		"VA DMIC4", "VA MIC BIAS4",
		"VA DMIC5", "VA MIC BIAS4",
		"VA SWR_ADC0", "VA_SWR_CLK",
		"VA SWR_ADC1", "VA_SWR_CLK",
		"VA SWR_ADC2", "VA_SWR_CLK",
		"VA SWR_ADC3", "VA_SWR_CLK",
		"VA SWR_MIC0", "VA_SWR_CLK",
		"VA SWR_MIC1", "VA_SWR_CLK",
		"VA SWR_MIC2", "VA_SWR_CLK",
		"VA SWR_MIC3", "VA_SWR_CLK",
		"VA SWR_MIC4", "VA_SWR_CLK",
		"VA SWR_MIC5", "VA_SWR_CLK",
		"VA SWR_MIC6", "VA_SWR_CLK",
		"VA SWR_MIC7", "VA_SWR_CLK",
		"VA SWR_ADC0", "ADC1_OUTPUT",
		"VA SWR_ADC2", "ADC2_OUTPUT",
		"VA SWR_ADC3", "ADC3_OUTPUT",
		"VA SWR_MIC0", "DMIC1_OUTPUT",
		"VA SWR_MIC1", "DMIC2_OUTPUT",
		"VA SWR_MIC2", "DMIC3_OUTPUT",
		"VA SWR_MIC3", "DMIC4_OUTPUT",
		"VA SWR_MIC4", "DMIC5_OUTPUT",
		"VA SWR_MIC5", "DMIC6_OUTPUT",
		"VA SWR_MIC6", "DMIC7_OUTPUT",
		"VA SWR_MIC7", "DMIC8_OUTPUT";
	qcom,msm-mbhc-hphl-swh = <0>;
	qcom,msm-mbhc-gnd-swh = <0>;
	qcom,wsa-max-devs = <1>;
	qcom,wsa-devs = <&wsa883x_0221>;
	qcom,wsa-aux-dev-prefix = "SpkrLeft";
	qcom,codec-max-aux-devs = <1>;
	qcom,msm-mbhc-usbc-audio-supported = <1>;
	qcom,codec-aux-devs = <&wcd937x_codec>;
	qcom,msm_audio_ssr_devs = <&audio_apr>, <&q6core>,
				<&lpi_tlmm>, <&bolero>;
};

&qupv3_se8_i2c {
	#address-cells = <1>;
	#size-cells = <0>;

	status = "ok";
	qcom,i2c-touch-active = "focaltech,fts_ts";

	focaltech@38 {
		compatible = "focaltech,fts_ts";
		reg = <0x38>;
		interrupt-parent = <&tlmm>;
		interrupts = <22 0x2008>;
		focaltech,reset-gpio = <&tlmm 21 0x00>;
		focaltech,irq-gpio = <&tlmm 22 0x2008>;
		focaltech,max-touch-number = <5>;
		focaltech,display-coords = <0 0 1080 2340>;

		vdd-supply = <&L6A>;

		pinctrl-names = "pmx_ts_active", "pmx_ts_suspend","pmx_ts_release";
		pinctrl-0 = <&ts_active>;
		pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;
		pinctrl-2 = <&pmx_ts_release>;

		panel = <&dsi_r66451_amoled_60hz_cmd
			 &dsi_r66451_amoled_90hz_cmd
			 &dsi_r66451_amoled_120hz_cmd
			 &dsi_r66451_amoled_60hz_video
			 &dsi_r66451_amoled_90hz_video
			 &dsi_r66451_amoled_120hz_video>;
	};
};

&pm7250b_vadc {
	smb1390_therm@e {
		qcom,scale-fn-type = <ADC_SCALE_HW_CALIB_PM5_SMB1398_TEMP>;
	};
};

&pm7250b_gpios {
	smb_stat {
		smb_stat_default: smb_stat_default {
			pins = "gpio6";
			function = "normal";
			input-enable;
			bias-pull-up;
			qcom,pull-up-strength = <PMIC_GPIO_PULL_UP_30>;
			power-source = <0>;
		};
	};
};

&qupv3_se10_i2c {
	qcom,clk-freq-out = <100000>;
	status = "ok";
	#include "smb1398.dtsi"
};

&smb1396 {
	interrupts = <0x2 0xc5 0x0 IRQ_TYPE_LEVEL_LOW>;
	interrupt-parent = <&spmi_bus>;
	interrupt-names = "smb1396";
	pinctrl-names = "default";
	qcom,enable-toggle-stat;
	pinctrl-0 = <&smb_stat_default>;
	status = "ok";
};

&smb1396_div2_cp_master {
	io-channels = <&pm7250b_vadc ADC_AMUX_THM2>;
	qcom,parallel-input-mode = <1>; /* USBIN */
	qcom,parallel-output-mode = <2>; /* VBAT */
	qcom,div2-cp-min-ilim-ua = <750000>;
	status = "ok";
};

&smb1396_slave {
	status = "ok";
};

&smb1396_div2_cp_slave {
	status = "ok";
};

&qusb_phy0 {
	qcom,qusb-phy-init-seq =
		/* <value reg_offset> */
		<0x23 0x210 /* PWR_CTRL1 */
		 0x03 0x04  /* PLL_ANALOG_CONTROLS_TWO */
		 0x7c 0x18c /* PLL_CLOCK_INVERTERS */
		 0x80 0x2c  /* PLL_CMODE */
		 0x0a 0x184 /* PLL_LOCK_DELAY */
		 0x19 0xb4  /* PLL_DIGITAL_TIMERS_TWO */
		 0x40 0x194 /* PLL_BIAS_CONTROL_1 */
		 0x16 0x198 /* PLL_BIAS_CONTROL_2 */
		 0x21 0x214 /* PWR_CTRL2 */
		 0x08 0x220 /* IMP_CTRL1 */
		 0x58 0x224 /* IMP_CTRL2 */
		 0x47 0x240 /* TUNE1 */
		 0x29 0x244 /* TUNE2 */
		 0xca 0x248 /* TUNE3 */
		 0x04 0x24c /* TUNE4 */
		 0x03 0x250 /* TUNE5 */
		 0x30 0x23c /* CHG_CTRL2 */
		 0x22 0x210>; /* PWR_CTRL1 */

	qcom,qusb-phy-host-init-seq =
		/* <value reg_offset> */
		<0x23 0x210 /* PWR_CTRL1 */
		0x03 0x04  /* PLL_ANALOG_CONTROLS_TWO */
		0x7c 0x18c /* PLL_CLOCK_INVERTERS */
		0x80 0x2c  /* PLL_CMODE */
		0x0a 0x184 /* PLL_LOCK_DELAY */
		0x19 0xb4  /* PLL_DIGITAL_TIMERS_TWO */
		0x40 0x194 /* PLL_BIAS_CONTROL_1 */
		0x16 0x198 /* PLL_BIAS_CONTROL_2 */
		0x21 0x214 /* PWR_CTRL2 */
		0x08 0x220 /* IMP_CTRL1 */
		0x58 0x224 /* IMP_CTRL2 */
		0x47 0x240 /* TUNE1 */
		0x29 0x244 /* TUNE2 */
		0xca 0x248 /* TUNE3 */
		0x04 0x24c /* TUNE4 */
		0x03 0x250 /* TUNE5 */
		0x30 0x23c /* CHG_CTRL2 */
		0x22 0x210>; /* PWR_CTRL1 */
};

&tlmm {
	fpc_reset_int: fpc_reset_int {
		fpc_reset_low: reset_low {
			mux {
				pins = "gpio18";
				function = "gpio";
			};

			config {
				pins = "gpio18";
				drive-strength = <2>;
				bias-disable;
				output-low;
			};
		};

		fpc_reset_high: reset_high {
			mux {
				pins = "gpio18";
				function = "gpio";
			};

			config {
				pins = "gpio18";
				drive-strength = <2>;
				bias-disable;
				output-high;
			};
		};

		fpc_int_low: int_low {
			mux {
				pins = "gpio17";
				function = "gpio";
			};

			config {
				pins = "gpio17";
				drive-strength = <2>;
				bias-pull-down;
				input-enable;
			};
		};
	};
};

&soc {
	fingerprint: fpc1020 {
		compatible = "fpc,fpc1020";
		interrupt-parent = <&tlmm>;
		interrupts = <17 0>;
		fpc,gpio_rst = <&tlmm 18 0>;
		fpc,gpio_irq = <&tlmm 17 0>;
		fpc,enable-on-boot;
		pinctrl-names = "fpc1020_reset_reset",
				"fpc1020_reset_active",
				"fpc1020_irq_active";
		pinctrl-0 = <&fpc_reset_low>;
		pinctrl-1 = <&fpc_reset_high>;
		pinctrl-2 = <&fpc_int_low>;
	};
};
